package com.chenglu.android.couponcenter.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.index.bean.TabTitleBean;

import java.util.List;

/**c
 * @author: lyj
 * @Created: by Copyright 2023/3/13 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：领劵中心adapter数据
 */
public class CenterTabAdapter extends BaseQuickAdapter<TabTitleBean.Data, BaseViewHolder> {

    private Context mContext ;
    public CenterTabAdapter(@Nullable Context context, List<TabTitleBean.Data> data) {
        super(R.layout.item_center_tab_title, data);
        this.mContext = context;

    }



    @Override
    protected void convert(@NonNull BaseViewHolder helper, TabTitleBean.Data item) {

        if (item != null) {

            TextView textView = helper.getView(R.id.tv_item_title);
            ImageView imageView = helper.getView(R.id.iv_item_supply);

            textView.setText(item.getMenuName());

            if(helper.getAdapterPosition()== getThisPosition()){
                textView.setTextSize(16);
                textView.setTextColor(mContext.getResources().getColor(R.color.all_black_text));
                imageView.setBackground(mContext.getResources().getDrawable(R.drawable.supply_icon_select));
                imageView.setVisibility(View.VISIBLE);
            }else {
//                imageView.setBackground(mcontext.getResources().getDrawable(R.drawable.supply_icon_select));
                imageView.setVisibility(View.INVISIBLE);
                textView.setTextSize(14);
                textView.setTextColor(mContext.getResources().getColor(R.color.all_grey_text));
            }



        }
    }


    private int  thisPosition = 0;

    public int getThisPosition() {
        return thisPosition;
    }

    public void setThisPosition(int thisPosition) {
        this.thisPosition = thisPosition;
        notifyDataSetChanged();
    }
}
